home *** CD-ROM | disk | FTP | other *** search
- ' BASEBALL.BAS
- ' This program keeps score for a nine-inning baseball game with a
- ' two-dimensional array named scoreboard%.
-
- OPTION BASE 1 ' set first array element at 1
- DIM scoreboard%(2, 9) ' dimension 2x9 array for baseball scoreboard
-
- ' get team and mascot names
-
- visitor$ = "Boston": visitorMascot$ = "Red Sox"
- home$ = "Seattle": homeMascot$ = "Mariners"
-
- CLS
-
- PRINT "Enter runs scored by each team in a nine-inning baseball game."
- PRINT
-
- FOR inning% = 1 TO 9 ' get number of runs scored in each inning
- PRINT "Inning"; inning%; "--> "; visitor$;
- INPUT ; ": ", scoreboard%(1, inning%)
- PRINT " "; home$;
- INPUT ": ", scoreboard%(2, inning%)
- ' ...and keep running total for each team
- visitorScore% = visitorScore% + scoreboard%(1, inning%)
- homeScore% = homeScore% + scoreboard%(2, inning%)
- NEXT inning%
-
- ' determine the winner of the game and display results
-
- PRINT
- COLOR 2 ' set foreground color to green for "news flash"
-
- IF (visitorScore% > homeScore%) THEN
- PRINT "News Flash: "; visitorMascot$; " beat "; homeMascot$;
- PRINT visitorScore%; "to"; homeScore%
- ELSEIF (homeScore% > visitorScore%) THEN
- PRINT "News Flash: "; homeMascot$; " beat "; visitorMascot$;
- PRINT homeScore%; "to"; visitorScore%
- ELSE
- PRINT "News Flash: "; visitorMascot$; " tie "; homeMascot$;
- PRINT visitorScore%; "to"; homeScore%
- END IF
-
- COLOR 7 ' set foreground color to white
-
- ' display the final scoreboard
-
- PRINT
- PRINT "Inning 1 2 3 4 5 6 7 8 9"
- PRINT "--------------------------------------------------------"
-
- FOR team% = 1 TO 2 ' for each team in the game
- IF (team% = 1) THEN PRINT visitor$, ELSE PRINT home$,
- FOR inning% = 1 TO 9 ' ...and for each inning in the game...
- PRINT scoreboard%(team%, inning%); " ";
- NEXT inning% ' print the number of runs scored
- PRINT
- NEXT team%
-
-